home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
UTIL
/
Folder・Icon・Opener 1.0.1.sit
/
Folder•Icon•Opener 1.0.1
/
source code
/
sources
/
FIOpen.draw.c
< prev
next >
Wrap
Text File
|
1996-05-05
|
5KB
|
184 lines
/*
*--------------------------------------------------------------
* FIOpen.draw.c
*--------------------------------------------------------------
* Copyright ゥ Fumio Rokkaku, 1996
*--------------------------------------------------------------
*/
#pragma once
/* System Headers */
#include <QuickDraw.h>
#include <Windows.h>
#include <Dialogs.h>
#include <Controls.h>
#include <Palettes.h>
#include <OSUtils.h>
#include <Icons.h>
#include <Gestalt.h>
#include <Errors.h>
/* Project Headers */
#include "FIOpen.h"
/*
*--------------------------------------------------------------
* global flags to check QuickDraw version
*--------------------------------------------------------------
*/
long gQDVersion;
/*
*--------------------------------------------------------------
* type definitions for custom drawing routines
*--------------------------------------------------------------
*/
typedef struct {
RectPtr rect;
Boolean flag;
} DrawPrmRec, *DrawPrmPtr;
/*
*--------------------------------------------------------------
* prototypes of device loop callback routines
*--------------------------------------------------------------
*/
static pascal void DrawEachRaisedRect(short dpt, short flg, GDHandle gdv, long ref);
/*
*--------------------------------------------------------------
* static function prototypes used within this source
*--------------------------------------------------------------
*/
static void DrawDeepRaisedRect(RectPtr, GDHandle);
static void DrawBMapRaisedRect(RectPtr);
/*
*--------------------------------------------------------------
* GetQuickDrawVersion
*--------------------------------------------------------------
* frame bold round rect to default button
*--------------------------------------------------------------
*/
void GetQuickDrawVersion(void)
{
OSErr result;
result = Gestalt(gestaltQuickdrawVersion, &gQDVersion);
if (result != noErr) {
gQDVersion = gestaltOriginalQD;
}
}
/*
*--------------------------------------------------------------
* RaisedRect
*--------------------------------------------------------------
* draw rased rectangle frame
*--------------------------------------------------------------
*/
void RaisedRect(const RectPtr theRect)
{
Rect drawRect;
PenState curPen;
GetPenState(&curPen);
PenNormal();
drawRect.top = theRect->top;
drawRect.left = theRect->left;
drawRect.bottom = theRect->bottom -1;
drawRect.right = theRect->right -1;
/* check the QuickDraw version */
if (gQDVersion >= gestalt8BitQD) {
DeviceLoopDrawingUPP RaisedUPP;
RaisedUPP = NewDeviceLoopDrawingProc(DrawEachRaisedRect);
/* call the device loop callback */
if (RaisedUPP != nil) {
RgnHandle drawRgn = NewRgn();
RectRgn(drawRgn, &drawRect);
DeviceLoop(drawRgn, RaisedUPP, (long)&drawRect, 0);
DisposeRoutineDescriptor(RaisedUPP);
DisposeRgn(drawRgn);
}
} else {
DrawBMapRaisedRect(&drawRect);
}
SetPenState(&curPen);
}
/*
*--------------------------------------------------------------
* DrawEachRaisedRect
*--------------------------------------------------------------
* raised rectangle drawing device loop callback
*--------------------------------------------------------------
*/
static pascal void DrawEachRaisedRect(
short howDeep,
short theFlag,
GDHandle theDevice,
long userData)
{
#pragma unused(theFlag)
RectPtr drawRect = (RectPtr)userData;
if (howDeep > 1) {
DrawDeepRaisedRect(drawRect, theDevice);
} else {
DrawBMapRaisedRect(drawRect);
}
}
/*
*--------------------------------------------------------------
* DrawDeepRaisedRect
*--------------------------------------------------------------
* raised rectangle drawing routine on the deep device
*--------------------------------------------------------------
*/
static void DrawDeepRaisedRect(RectPtr theRect, GDHandle theDevice)
{
RGBColor foreColor, backColor, grayColor;
GetForeColor(&foreColor);
GetBackColor(&backColor);
grayColor = foreColor;
if (GetGray(theDevice, &backColor, &grayColor)) {
ForeColor(whiteColor);
MoveTo(theRect->left, theRect->bottom);
LineTo(theRect->left, theRect->top);
LineTo(theRect->right, theRect->top);
RGBForeColor(&grayColor);
LineTo(theRect->right, theRect->bottom);
LineTo(theRect->left, theRect->bottom);
RGBForeColor(&foreColor);
} else {
DrawBMapRaisedRect(theRect);
}
}
/*
*--------------------------------------------------------------
* DrawBMapRaisedRect
*--------------------------------------------------------------
* raised rectangle drawing routine on the bitmap device
*--------------------------------------------------------------
*/
static void DrawBMapRaisedRect(RectPtr theRect)
{
long darkPat[2], litePat[2];
darkPat[0] = darkPat[1] = 0xFFFFFFFF;
litePat[0] = litePat[1] = 0xAA55AA55;
PenPat((PatPtr)litePat);
MoveTo(theRect->left, theRect->bottom);
LineTo(theRect->left, theRect->top);
LineTo(theRect->right, theRect->top);
PenPat((PatPtr)darkPat);
LineTo(theRect->right, theRect->bottom);
LineTo(theRect->left, theRect->bottom);
}